<!--
 * @Author: 陆成杰
 * @Date: 2022-06-25 08:46:57
 * @LastEditTime: 2022-06-25 10:06:20
 * @LastEditors: 陆成杰
 * @FilePath: /boe/src/views/home/home-children/Materials.vue
 * Copyright (c) ${now_year} by zucc-陆成杰, All Rights Reserved. 
-->
<template>
  <div class="echart" id="mychart1" :style="myChartStyle"></div>
</template>
 
<script>
import * as echarts from "echarts";

export default {
  data() {
    return {
      xData: ["轮播测试", "123"], //横坐标
      yData: [1, 0], //数据
      myChartStyle: { float: "left", width: "200px", height: "200px" }, //图表样式
    };
  },
  mounted() {
    this.initEcharts();
  },
  methods: {
    initEcharts() {
      const option = {
        tooltip: {
          trigger: "item",
        },
        color: ['rgb(220, 187, 56)', 'rgb(24, 144, 255)', 'rgb(151, 95, 229)'],
        series: [
          {
            name: "素材资源",
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: true,
              position: "center",
              color:'#fff',
              formatter: '{c} KB'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: "40",
                fontWeight: "bold",
              },
            },
            labelLine: {
              show: false,
            },
            data: [
              { value: 1048, name: "图片" },
              { value: 735, name: "视频" },
              { value: 580, name: "音频" },
            ],
          },
        ],
      };
      const myChart1 = echarts.init(document.getElementById("mychart1"));
      myChart1.setOption(option);
      //随着屏幕大小调节图表
      window.addEventListener("resize", () => {
        myChart1.resize();
      });
    },
  },
};
</script>